/// 结构体
struct User {
    name: String,
}

impl User {
    fn hello() {
        println!("hello world");
    }
    fn say(&self) {
        println!("{}", self.name);
    }
}

fn main() {
    let user = User {
        name: String::from("hello user"),
    };
    User::hello();
    user.say();

    let mut guess = String::new();
    /// 引用类型
    /// &mut guess : 变量"guess"的引用; 它允许多处代码访问同一处数据，而无需在内存中多次拷贝。
    /// read_line 的工作是, 无论用户在标准输入中键入什么内容, 都将其追加（不会覆盖其原有内容）到一个字符串中。
    std::io::stdin()
        .read_line(&mut guess)
        .expect("Failed to read line");
    println!("You guessed: {}", guess);

    
    let s = String::from("hello world");
    let s_ref = &s;
    println!("我是s:{}", s);
    println!("我是&s:{}", &s);
    println!("我是&s -> pointer:{:p}", &s);
    println!("我是s_ref:{}", s_ref);
    println!("我是*s_ref:{}", *s_ref);
    println!("---------------------");
    println!("我是&s_ref:{}", &s_ref);
    println!("我是s_ref -> pointer:{:p}", s_ref);
    println!("我是&s_ref -> pointer::{:p}", &s_ref);
}
